import { ModuleInfo } from "../../../com/gengine/modules/ModuleInfo";
import { ModuleManager } from "../../../com/gengine/modules/ModuleManager";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
//class ModuleConfig
    
    export  class ModuleConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._list = new Array<any>();
            if (ModuleConfig._instance != null) 
            {
                throw new Error(" ModuleConfig 单例 ");
            }
            ModuleConfig._instance = this;
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new ModuleInfo();
                loc1.url = loc2.url;
                loc1.name = loc2.name;
                loc1.isLoaded = loc2.isLoaded;
                loc1.isLoading = loc2.isLoading;
                loc1.error = loc2.error;
                loc1.module = loc2.module;
                this._map[loc1.name] = loc1;
                this._list.push(loc1);
            }
            ModuleManager.instance.loadModuleInfo(this._list);
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getObjectByFileName("module.xml");
            this.write(loc1);
            return;
        }

        public getInfoByName(arg1: string): ModuleInfo
        {
            return this._map[arg1];
        }

        public static get instance(): ModuleConfig
        {
            if (ModuleConfig._instance == null) 
            {
                ModuleConfig._instance = new ModuleConfig();
            }
            return ModuleConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_list: Array<any>;

        /* internal */ static /* var */_instance: ModuleConfig;
    }
